//
//  BaseCollectionReusableView.m
//  礼物说
//
//  Created by dllo on 16/5/4.
//  Copyright © 2016年 sunzhichao. All rights reserved.
//

#import "BaseCollectionReusableView.h"

@implementation BaseCollectionReusableView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        
        [self createReusableView];
    }
    return self;
}
- (void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"day" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"night" object:nil];
    
    [super dealloc];
}
- (void)createReusableView{

    BOOL result = [[NSUserDefaults standardUserDefaults] boolForKey:@"isNight"];
    
    if (result == YES) {
        
        self.backgroundColor = [UIColor colorWithWhite:0.200 alpha:1.000];
        
    }else{
        
        self.backgroundColor = [UIColor whiteColor];
        
    }
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nightAction:) name:@"night" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dayAction:) name:@"day" object:nil];
}

- (void)nightAction:(NSNotification *)notification {
    
    self.backgroundColor = [UIColor colorWithWhite:0.200 alpha:1.000];
    
    
    
}

- (void)dayAction:(NSNotification *)notification {
    
    NSLog(@"日间模式开启成功");
    
    self.backgroundColor = [UIColor whiteColor];
}


@end
